﻿using System;
using System.Collections.Generic;
using System.Text;
using Infrastructure.Lib.Core;

namespace CrmSpider.Model
{
    public class ContactCollection : List<ContactModel>
    {
        public ContactCollection(string customerName, string oriStr)
        {
            var contactStr = oriStr.Substring2("x28_state[\\s\\S]+?\"Values\": ", ",\r", true);
            var contacts = contactStr.JsonToModels<List<List<string>>>();

            foreach (var c in contacts)
            {
                var cm = new ContactModel()
                {
                    CustomerName = customerName,
                    Contact = c[2],
                    PhoneNumber = c[3],
                    Email = c[4],
                    QQ = c[5],
                    Position = c[6],
                    Administrative = c[7],
                    Situation = c[8]
                };
                this.Add(cm);
            }
        }
    }
}
